// document.cookie="token=82b6f469b4bd613a1b2ee10bb4d0afabbf4d7865"
getCookie=function(name){
	var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr!=null)return unescape(arr[2]); return "";
}
var token= getCookie("token");
$(function(){
	////	获取个人资料
	//$.ajax({
	//	url:'http://ww.yc630.com/api/index.php/Buyer/User/userinfo',
	//	type:"post",
	//	data:{
	//		'token':token
	//	},
	//	dataType:"JSON",
	//	success:function(data){
	//		var avatar = data['data']['avatar'];
	//		if(avatar==''){
	//			avatar = '../img/Group%2019.png';
	//		}
	//		$("#headPic").attr('src',avatar)
	//	}
	//})
	//左侧菜单悬停
	$(".list_menu li").hover(function(){
		var index=$(this).index()
		if(index==0||index==5||index==8){
			$(this).css('backgroundColor','#ffffff')
		}
		else {
			$(this).css('backgroundColor','#FEE631')
		}
	},function(){
		var index=$(this).index()
		if(index==2){
			$(this).css('backgroundColor','#FEE631')
		}
		else{
			$(this).css('backgroundColor','#ffffff')
		}
	})
	//获得商家信息
	$.ajax({
		type:"post",
		url:"http://ww.yc630.com/api/index.php/Buyer/Goods/sellerdetail",
		data:{
			'token':token
		},
		dataType:'json',
		success:function(data){
			$("#icon_img").attr('src',data.data.icon_image)
			$("#icon_name").html(data.data.name)
		}
	});
	//获得品牌列表
	$.ajax({
		type:"post",
		url:"http://ww.yc630.com/api/index.php/Seller/Goods/brandist",
		data:{
			'token':token
		},
		dataType:'json',
		success:function(phpdata){
			var str = '';
			for(i in phpdata['data']){
				
				 str += '<option value="'+i+'">'+phpdata['data'][i]+'</option>';				
			}

			$('select[name="brand"]').append(str);
		}
		
	});
	
	//获得人群风格
	$.ajax({
		type:"post",
		url:"http://ww.yc630.com/api/index.php/Seller/Goods/peopleStylelist",
		data:{
			'token':token
		},
		dataType:'json',
		success:function(phpdata){
			var str = '';
			for(i in phpdata['data']){
				
				 str += '<option value="'+i+'">'+phpdata['data'][i]+'</option>';				
			}

			$('select[name="people_style"]').append(str);
			
		}
	});
	//获得购买属性
	$.ajax({
		type:"post",
		url:"http://ww.yc630.com/api/index.php/Seller/Belong/belong_list",
		data:{
			'token':token
		},
		dataType:'json',
		success:function(phpdata){
			var str = '';
			for(i in phpdata['data']['tpls']){
				
				 str += '<option value="'+phpdata['data']['tpls'][i]['id']+'">'+phpdata['data']['tpls'][i]['tpl_name']+'</option>';				
			}

			$('select[name="attr"]').append(str);
			
		}
	});
	
	//发货地省
	$.ajax({
			type:"post",
			url:"http://ww.yc630.com/api/index.php/Buyer/User/getProvince",
			data:{
				'token':token
			},
			dataType:'json',
			success:function(phpdata){
				var opt = '';
				$.each(phpdata['data'], function(k,v) {
					
					opt +='<option value="'+k+'">'+v+'</option>';
				});
				$('select[name="shipaddress_province"]').append(opt);
			}
		});
	
	
	//发货地市区
	$('select[name="shipaddress_province"]').change(function(){
			$('select[name="shipaddress_city"]').html('<option value="0">请选择市、区</option>');
			var provinceid = $(this).children(':selected').val();
			
			$.ajax({
				type:"post",
				data:{'provinceid':provinceid,'token':token},
				url:"http://ww.yc630.com/api/index.php/Buyer/User/getCity",
				dataType:'json',
				success:function(phpdata){
					var opt = '';
					$.each(phpdata['data'], function(k,v) {
						
						opt +='<option value="'+k+'">'+v+'</option>';
					});
					$('select[name="shipaddress_city"]').append(opt);
					}
			});
		})
	//获得商品风格
	$('select[name="people_style"]').change(function(){
		var people_style = $(this).val();
		$('select[name="goods_style"]').html('<option value="0">请选择适宜风格</option>');
		if(people_style == 0){
			$('select[name="goods_style"]').html('<option value="0">请选择适宜风格</option>');
			return false;
		}
		$.ajax({
			type:"post",
			url:"http://ww.yc630.com/api/index.php/Seller/Goods/goodsStylelist",
			data:{'people_style':people_style,'token':token},
			dataType:'json',
			success:function(phpdata){
				var str = '';
				for(i in phpdata['data']){
					
					 str += '<option value="'+i+'">'+phpdata['data'][i]+'</option>';				
				}
	
				$('select[name="goods_style"]').append(str);
			}
		});
	})
	
	
	//产地省
	$.ajax({
			type:"post",
			url:"http://ww.yc630.com/api/index.php/Buyer/User/getProvince",
			data:{
				'token':token
			},
			dataType:'json',
			success:function(phpdata){
				var opt = '';
				$.each(phpdata['data'], function(k,v) {
					
					opt +='<option value="'+k+'">'+v+'</option>';
				});
				$('select[name="prodaddress_province"]').append(opt);
			}
		});
	
	
	//产地市区
	$('select[name="prodaddress_province"]').change(function(){
			$('select[name="prodaddress_city"]').html('<option value="0">请选择市、区</option>');
			var provinceid = $(this).children(':selected').val();
			
			$.ajax({
				type:"post",
				data:{'provinceid':provinceid,'token':token},
				url:"http://ww.yc630.com/api/index.php/Buyer/User/getCity",
				dataType:'json',
				success:function(phpdata){
					var opt = '';
					$.each(phpdata['data'], function(k,v) {
						
						opt +='<option value="'+k+'">'+v+'</option>';
					});
					$('select[name="prodaddress_city"]').append(opt);
					}
			});
		})
	
	//获得运费模板
	$.ajax({
		type:"post",
		url:"http://ww.yc630.com/api/index.php/Seller/Freight/freight_list",
		data:{
			'token':token
		},
		dataType:'json',
		success:function(phpdata){
			var str = '';
			for(i in phpdata['data']){
				
				 str += '<option value="'+phpdata['data'][i]['id']+'">'+phpdata['data'][i]['name']+'</option>';				
			}

			$('select[name="freight_name"]').append(str);
		}
	});
	
	//图片上传
	$("#file_upload").uploadify({	 
	 	
        'swf'           : '../uploadify/uploadify.swf',
        'uploader'      : 'http://ww.yc630.com/api/index.php/Seller/Seller/upload',      
        'width':58,
	    'height':58,
        'multi'         : true,
        'removeTimeout' : 0.2,//成功显示时间
        'fileTypeExts' : '*.jpg;*.png',
        'scriptAccess' : 'always',
        'onUploadSuccess' : function(file, data, response) {
        	var img_len = $('.imgs').length
        	if(img_len >= 5){

                 alert('最多可上传五张图片');
                 return false;
        	}
            data=$.parseJSON(data);
            
            var str = '<div style="position: relative" class="add_pic_btn imgs"><img img_id="'+data['data'][0]['imageid']+'"  src="'+data['data'][0]['image']+'"/><span class="little_sc" onclick="sc(this)">X</span></div>';
            $('.goods_img').prepend(str);
                     
        }


    });
	
	
	
	//属性模板详情
	$('select[name="attr"]').change(function(){
		var id = $(this).val();
		$('.attr_table').html('');
		
		$.ajax({
			type:"post",
			url:"http://ww.yc630.com/api/index.php/Seller/Belong/belong_detail",
			data:{'id':id,'token':token},
			dataType:'json',
			success:function(phpdata){
				var str = '';
				var price_attr = '';
				price_attr +='<input class="z_s" type="radio" name="price_attr" id="统一定价"><label class="z_label" for="统一定价">统一定价</label>'
				for(i in phpdata['data'][id]['attr']){					
					str +='<tr><td class="z_td_w" name="'+phpdata['data'][id]['attr'][i]['attr_name']+'" style="text-align: left;width: 60px;">'+phpdata['data'][id]['attr'][i]['attr_name']+':</td><td>';
					 var attrs = phpdata['data'][id]['attr'][i]['value'].split(',');
					for(j in attrs){
						str +='<input class="z_s z_attrs" z_shu="'+phpdata['data'][id]['attr'][i]['attr_name']+'" z_names="'+attrs[j]+'" type="checkbox" name=""  /> <label class="z_label">'+attrs[j]+'</label> ' ;
					}
					str +='<a href="###" attr_name="'+phpdata['data'][id]['attr'][i]['attr_name']+'" class="hand_add hand_a" >添加</a></td></tr>';
					
					price_attr += '<input class="z_s" type="radio" name="price_attr" id="'+phpdata['data'][id]['attr'][i]['attr_name']+'" /><label class="z_label" for="'+phpdata['data'][id]['attr'][i]['attr_name']+'">按'+phpdata['data'][id]['attr'][i]['attr_name']+'设定</label>';
				}
				$('.price_attr').html(price_attr);
				$('.attr_table').html(str);
				$('.attr_list').html('');
			}
		});
		
	})
	
	//属性值复选框发生变化 价格设定 html发生变化
	$('.z_table').on('change','.z_attrs',function(){
		var z_shu = $(this).attr('z_shu');
		var price_attr =  $('input:radio[name="price_attr"]:checked').attr('id');
		

		var str = '<tr class="z_head"><td>条形码</td><td>'+price_attr+'</td><td>销售价</td><td>原价</td><td>库存</td></tr>';
		if($(this).is(':checked')){

			if(z_shu == price_attr){
				$('input:checkbox[z_shu='+z_shu+']:checked').each(function(i){
					var z_names = $(this).attr('z_names');
					str +='<tr class="z_list_main"><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td>'+z_names+'</td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
				})
				$('.attr_list').html(str);
				
			}
			
		}else{
			
			if(z_shu == price_attr){
				$('input:checkbox[z_shu='+z_shu+']:checked').each(function(i){
					var z_names = $(this).attr('z_names');
					str +='<tr class="z_list_main"><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td>'+z_names+'</td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
				})
				$('.attr_list').html(str);
				
			}
			
		}
		
	})
	
	
	
	
	//添加属性
	$('.hand_and').click(function(){
		
		var title_con = '请输入想要添加的属性';
		var price_attr = '';
		layer.prompt({title: title_con, formType: 0}, function(pass, index){
		  layer.close(index);
		  var str = '<tr><td class="z_td_w" name="'+pass+'" style="text-align: left;width: 60px;">'+pass+':</td><td><a href="###" attr_name="'+pass+'" class="hand_add hand_a" >添加</a></td></tr>';
		  price_attr += '<input class="z_s" type="radio" name="price_attr" id="'+pass+'" /><label class="z_label" for="'+pass+'">按'+pass+'设定</label>';
          $('.price_attr').append(price_attr);
		  $('.attr_table').append(str);
		  
        });
		
	})
	
	//添加属性值
	$('.attr_table').on('click','.hand_a',function(){

		var attr_name = $(this).attr('attr_name');
		var title_con = '请输入想要添加的'+attr_name;
		$this=$(this);
		layer.prompt({title: title_con, formType: 0}, function(pass, index){
		  layer.close(index);
		  var str = '<input class="z_s z_attrs" z_shu="'+attr_name+'" z_names="'+pass+'" type="checkbox" name=""  /> <label class="z_label">'+pass+'</label>'

          
		  $this.parent('td').prepend(str);
		  
        });
	})
	
	//价格设定的属性
	$('.price_attr').on('change','input:radio[name="price_attr"]',function(){
		var price_attr =  $('input:radio[name="price_attr"]:checked').attr('id');
		var str = '<tr class="z_head"><td>条形码</td><td>'+price_attr+'</td><td>销售价</td><td>原价</td><td>库存</td></tr>';
		if(price_attr == "统一定价"){
			str +='<tr class="z_list_main"><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td>统一</td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
		}
		$('input:checkbox[z_shu='+price_attr+']:checked').each(function(i){
			var z_names = $(this).attr('z_names');
			str +='<tr class="z_list_main"><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td>'+z_names+'</td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
	})
		
		$('.attr_list').html(str);
		
	})
	
	
	
	
	$('.save_back').click(function(){
		var form = $(this).closest('form');
		var goods_name = form.find('input[name="goods_name"]').val();
		if(goods_name == ''){
			noticebox('提示','商品名不能为空',1);
			return false;
		}
		var brand = form.find('select[name="brand"]').val();
		if(brand == 0){
			
			noticebox('提示','品牌名不能为空',1);
			return false;
		}
		//人群风格
		var people_style = form.find('select[name="people_style"]').val();
		if(people_style == 0){
			noticebox('提示','人群风格不能为空',1);
			return false;
		}
		//商品风格
		var goods_style = form.find('select[name="goods_style"]').val();
		if(goods_style == 0){
			noticebox('提示','商品风格不能为空',1);
			return false;
		}
		
		
		//货号
		var artnu = form.find('input[name="artnu"]').val();
		if(artnu == ''){
			noticebox('提示','货号不能为空',1);
			return false;
		}
		//产地
		var prodaddress = form.find('select[name="prodaddress_city"]').val();
		if(prodaddress == 0){
			noticebox('提示','产地不能为空',1);
			return false;
		}
		//产地
		var prodprovince_address = form.find('select[name="prodaddress_province"]').val();
		if(prodaddress == 0){
			noticebox('提示','产地不能为空',1);
			return false;
		}
		//发货地
		var shipaddress = form.find('select[name="shipaddress_city"]').val();
		if(shipaddress == 0){
			noticebox('提示','发货地不能为空',1);
			return false;
		}
		//发货地
		var shipprovince_address = form.find('select[name="shipaddress_province"]').val();
		if(shipaddress == 0){
			noticebox('提示','发货地不能为空',1);
			return false;
		}
		//属性*
		// 遍历所有的table数据  
	    var html='';  
	    var tr_len = $('.attr_table').find('tr').length;
	    $('.attr_table').find('tr').each(function (i) { 
	    	
	            $(this).find('td').each(function () {   
	                if($(this).attr('class') == 'z_td_w'){
	                	html +=$(this).attr('name')+',';
	                }else{
	                	var len = $(this).find('input:checkbox:checked').length;
	                	
	                	$(this).find('input:checkbox:checked').each(function(i){
	                		if(len == (i+1)){
	                			html += $(this).attr('z_names');
	                		}else{
	                			html += $(this).attr('z_names')+',';
	                		}
	                			                		
	                	})
	                }
	            });  
	            if(tr_len != (i+1)){
	            	html +=";"
	            }
	            	           	           	              	           	           
	    });  
		
		var attr = html;
		if(attr == ''){
			noticebox('提示','商品属性不能为空',1);
			return false;
		}
		
		//定价属性*
		var price_attr = form.find('input:radio[name="price_attr"]:checked').attr('id');
		if(price_attr == ''){
			noticebox('提示','定价属性不能为空',1);
			return false;
		}
		
		//定价属性值**
		var list_len = $('.z_list_main').length;
		var price_attr_value = '';
		$('.z_list_main').each(function(i){
			
			var td_len = $(this).find('td').length;
			$(this).find('td').each(function(j){
			    if(j==1){
			    	price_attr_value += $(this).html()+',';
			    }else{
			    	if($(this).find('input:text').val() == ''){
			    		noticebox('提示','请填写完整定价属性值',1);
			    		return false;
			    	}
			    	if(td_len == (j+1)){
			    		price_attr_value += $(this).find('input:text').val();
			    	}else{
			    		price_attr_value += $(this).find('input:text').val()+',';
			    	}

			    }
				
			})
            if(list_len != (i+1)){
            	price_attr_value +=';'
            }
			
			
		})
		if(price_attr_value == ''){
			noticebox('提示','定价属性值不能为空',1);
			return false;
		}
		
				
		//库存提醒
		var notice_nu = form.find('input:radio[name="notice_nu"]:checked').val();
		if(notice_nu==1){
			var notice_nu = $('input[name="notice_nu_num"]').val();	
			
		}
		
		if(notice_nu==''){
			noticebox('提示','库存提醒不能为空',1);
		    return false;
		}
		//运费模板*
		var freightmodel = '';
		var freight = ''
		var freight = $('input[name="freight"]:checked').val();

		if(freight == 1){
			var freight_name = $('select[name="freight_name"]').val();
			if(freight_name == 0){

				noticebox('提示','请选择运费模板',1);
				return false;
			}
			var freightmodel = freight_name;
		}else{
			var freightmodel = freight;
		}
		if(freightmodel == ''){
		
			noticebox('提示','请选择运费',1);
		    return false;
		}
		//商品重量
		var weight = form.find('input[name="weight"]').val();
		if(weight == ''){

			noticebox('提示','重量不能为空',1);
		    return false;
		}
		
		//图片**
		var image = '';
		var img_len = $('.imgs').length;
		$('.imgs').each(function(i){
			if(img_len == (i+1)){
				image += $(this).find('img').attr('img_id');
			}else{
				image += $(this).find('img').attr('img_id')+',';
			}
			
		})
		if(image == ''){

			noticebox('提示','请上传商品图',1);
			return false;
		}
		//描述
		var describe =$('#myEditor').html();
		if(!describe){
			noticebox('提示','请填写详情描述',1);

			return false;
		}
		
		data = {};
		data['token']=token
		data['goods_name'] = goods_name;
		data['brand'] = brand;
		data['people_style'] = people_style;
		data['goods_style'] = goods_style;
		data['artnu'] = artnu;
		data['prodprovince_address'] = prodprovince_address;
		data['shipprovince_address'] = shipprovince_address;
		data['prodaddress'] = prodaddress;
		data['shipaddress'] = shipaddress;
		data['attr'] = attr;
		data['price_attr'] = price_attr;
        data['price_attr_value'] = price_attr_value;
        data['notice_nu'] = notice_nu;
        data['freightmodel'] = freightmodel;
        data['weight'] = weight;
        data['image'] = image;
        data['describe'] = describe;
        
        $.ajax({
        	type:"post",
        	url:"http://ww.yc630.com/api/index.php/Seller/Goods/goods_add",
        	data:data,
        	dataType:'json',
            success:function(phpdata){
				noticebox('提示','商品保存成功',1,'goods_house.html');
            }
        });
		
	})
	
	$('#fabu').click(function(){
			var form = $(this).closest('form');
		var goods_name = form.find('input[name="goods_name"]').val();
		if(goods_name == ''){
			noticebox('提示','商品名不能为空',1);
			return false;
		}
		var brand = form.find('select[name="brand"]').val();
		if(brand == 0){
			
			noticebox('提示','品牌名不能为空',1);
			return false;
		}
		//人群风格
		var people_style = form.find('select[name="people_style"]').val();
		if(people_style == 0){
			noticebox('提示','人群风格不能为空',1);
			return false;
		}
		//商品风格
		var goods_style = form.find('select[name="goods_style"]').val();
		if(goods_style == 0){
			noticebox('提示','商品风格不能为空',1);
			return false;
		}
		
		
		//货号
		var artnu = form.find('input[name="artnu"]').val();
		if(artnu == ''){
			noticebox('提示','货号不能为空',1);
			return false;
		}
		//产地
		var prodaddress = form.find('select[name="prodaddress_city"]').val();
		if(prodaddress == 0){
			noticebox('提示','产地不能为空',1);
			return false;
		}
		//产地
		var prodprovince_address = form.find('select[name="prodaddress_province"]').val();
		if(prodaddress == 0){
			noticebox('提示','产地不能为空',1);
			return false;
		}
		//发货地
		var shipaddress = form.find('select[name="shipaddress_city"]').val();
		if(shipaddress == 0){
			noticebox('提示','发货地不能为空',1);
			return false;
		}
		//发货地
		var shipprovince_address = form.find('select[name="shipaddress_province"]').val();
		if(shipaddress == 0){
			noticebox('提示','发货地不能为空',1);
			return false;
		}
		//属性*
		// 遍历所有的table数据  
	    var html='';  
	    var tr_len = $('.attr_table').find('tr').length;
	    $('.attr_table').find('tr').each(function (i) { 
	    	
	            $(this).find('td').each(function () {   
	                if($(this).attr('class') == 'z_td_w'){
	                	html +=$(this).attr('name')+',';
	                }else{
	                	var len = $(this).find('input:checkbox:checked').length;
	                	
	                	$(this).find('input:checkbox:checked').each(function(i){
	                		if(len == (i+1)){
	                			html += $(this).attr('z_names');
	                		}else{
	                			html += $(this).attr('z_names')+',';
	                		}
	                			                		
	                	})
	                }
	            });  
	            if(tr_len != (i+1)){
	            	html +=";"
	            }
	            	           	           	              	           	           
	    });  
		
		var attr = html;
		if(attr == ''){
			noticebox('提示','商品属性不能为空',1);
			return false;
		}
		
		//定价属性*
		var price_attr = form.find('input:radio[name="price_attr"]:checked').attr('id');
		if(price_attr == ''){
			noticebox('提示','定价属性不能为空',1);
			return false;
		}
		
		//定价属性值**
		var list_len = $('.z_list_main').length;
		var price_attr_value = '';
		$('.z_list_main').each(function(i){
			
			var td_len = $(this).find('td').length;
			$(this).find('td').each(function(j){
			    if(j==1){
			    	price_attr_value += $(this).html()+',';
			    }else{
			    	if($(this).find('input:text').val() == ''){
			    		noticebox('提示','请填写完整定价属性值',1);
			    		return false;
			    	}
			    	if(td_len == (j+1)){
			    		price_attr_value += $(this).find('input:text').val();
			    	}else{
			    		price_attr_value += $(this).find('input:text').val()+',';
			    	}

			    }
				
			})
            if(list_len != (i+1)){
            	price_attr_value +=';'
            }
			
			
		})
		if(price_attr_value == ''){
			noticebox('提示','定价属性值不能为空',1);
			return false;
		}
		
				
		//库存提醒
		var notice_nu = form.find('input:radio[name="notice_nu"]:checked').val();
		if(notice_nu==1){
			var notice_nu = $('input[name="notice_nu_num"]').val();	
			
		}
		
		if(notice_nu==''){
			noticebox('提示','库存提醒不能为空',1);
		    return false;
		}
		//运费模板*
		var freightmodel = '';
		var freight = ''
		var freight = $('input[name="freight"]:checked').val();

		if(freight == 1){
			var freight_name = $('select[name="freight_name"]').val();
			if(freight_name == 0){

				noticebox('提示','请选择运费模板',1);
				return false;
			}
			var freightmodel = freight_name;
		}else{
			var freightmodel = freight;
		}
		if(freightmodel == ''){
		
			noticebox('提示','请选择运费',1);
		    return false;
		}
		//商品重量
		var weight = form.find('input[name="weight"]').val();
		if(weight == ''){

			noticebox('提示','重量不能为空',1);
		    return false;
		}
		
		//图片**
		var image = '';
		var img_len = $('.imgs').length;
		$('.imgs').each(function(i){
			if(img_len == (i+1)){
				image += $(this).find('img').attr('img_id');
			}else{
				image += $(this).find('img').attr('img_id')+',';
			}
			
		})
		if(image == ''){

			noticebox('提示','请上传商品图',1);
			return false;
		}
		//描述

		//描述
		var describe =$('#myEditor').html();
		if(!describe){
			noticebox('提示','请填写详情描述',1);

			return false;
		}
		
		data = {};
		data['token']=token
		data['goods_name'] = goods_name;
		data['brand'] = brand;
		data['people_style'] = people_style;
		data['goods_style'] = goods_style;
		data['artnu'] = artnu;
		data['prodprovince_address'] = prodprovince_address;
		data['shipprovince_address'] = shipprovince_address;
		data['prodaddress'] = prodaddress;
		data['shipaddress'] = shipaddress;
		data['attr'] = attr;
		data['price_attr'] = price_attr;
        data['price_attr_value'] = price_attr_value;
        data['notice_nu'] = notice_nu;
        data['freightmodel'] = freightmodel;
        data['weight'] = weight;
        data['image'] = image;
        data['describe'] = describe;
        
        $.ajax({
        	type:"post",
        	url:"http://ww.yc630.com/api/index.php/Seller/Goods/goods_add",
        	data:data,
        	dataType:'json',
            success:function(phpdata){
				noticebox('提示','商品发布成功',1,'goods_house.html');				
            }
        });
	})
	$('#cancel').click(function(){
		noticebox('提示','您编辑的信息将无法保存，确定要不发布离开吗？',2,'goods_house.html');
		
	})
	
})
function sc(obj){
	$(obj).parent().remove()
}
